package yhao.demo.service.person.api;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yhao.demo.service.person.apilist.form.PersonEditForm;
import yhao.demo.service.person.apilist.form.PersonInsertForm;
import yhao.demo.service.person.apilist.form.PersonQueryForm;
import yhao.demo.service.person.apilist.model.PersonModel;
import yhao.demo.service.person.service.PersonService;
import yhao.infra.apilist.RequestResult;
import yhao.infra.apilist.RestfulBaseController;
import yhao.infra.apilist.validate.IdForm;
import yhao.infra.common.model.Pagination;

import javax.annotation.Resource;

/**
 * 人员记录微服务层Api
 * Created by yoara on 2019-03-28
 */
@RestController
@RequestMapping(value = "/person")
public class PersonApi extends RestfulBaseController {
    @Resource
    private PersonService personService;

    @PostMapping("/selectById")
    public RequestResult<PersonModel> selectById(@RequestBody IdForm form){
        return new RequestResult(personService.selectById(form));
    }

    @PostMapping("/insertPerson")
    public RequestResult<PersonInsertForm> insertPerson(@RequestBody PersonInsertForm form){
        return new RequestResult(personService.insertPerson(form));
    }

    @PostMapping("/editPerson")
    public RequestResult<PersonEditForm> editPerson(@RequestBody PersonEditForm form){
        return new RequestResult(personService.editPerson(form));
    }

    @PostMapping("/queryPersonPage")
    public RequestResult<Pagination<PersonModel>> queryPersonPage(@RequestBody PersonQueryForm form){
        return new RequestResult(personService.queryPersonPage(form));
    }

    @PostMapping("/deleteById")
    public RequestResult<IdForm> deleteById(@RequestBody IdForm form){
        return new RequestResult(personService.deleteById(form));
    }
}
